/*    */ package xin.petstore.framework.cas.session.redis;
/*    */ 
/*    */ import java.util.concurrent.ConcurrentHashMap;
/*    */ import java.util.concurrent.ConcurrentMap;
/*    */ import org.apache.shiro.cache.Cache;
/*    */ import org.apache.shiro.cache.CacheException;
/*    */ import org.apache.shiro.cache.CacheManager;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class RedisCacheManager
/*    */   implements CacheManager
/*    */ {
/* 15 */   private static final Logger logger = LoggerFactory.getLogger(RedisCacheManager.class);
/*    */ 
/* 18 */   private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap();
/*    */   private RedisManager redisManager;
/* 25 */   private String keyPrefix = "shiro_redis_cache:";
/*    */ 
/*    */   public String getKeyPrefix()
/*    */   {
/* 33 */     return this.keyPrefix;
/*    */   }
/*    */ 
/*    */   public void setKeyPrefix(String keyPrefix)
/*    */   {
/* 42 */     this.keyPrefix = keyPrefix;
/*    */   }
/*    */ 
/*    */   public <K, V> Cache<K, V> getCache(String name) throws CacheException
/*    */   {
/* 47 */     logger.debug("获取名称为: " + name + " 的RedisCache实例");
/*    */ 
/* 49 */     Cache c = (Cache)this.caches.get(name);
/*    */ 
/* 51 */     if (c == null)
/*    */     {
/* 54 */       this.redisManager.init();
/*    */ 
/* 57 */       c = new RedisCache(this.redisManager, this.keyPrefix);
/*    */ 
/* 60 */       this.caches.put(name, c);
/*    */     }
/* 62 */     return c;
/*    */   }
/*    */ 
/*    */   public RedisManager getRedisManager() {
/* 66 */     return this.redisManager;
/*    */   }
/*    */ 
/*    */   public void setRedisManager(RedisManager redisManager) {
/* 70 */     this.redisManager = redisManager;
/*    */   }
/*    */ }

/* Location:           C:\java代码反编译器\core-1.1.4.jar
 * Qualified Name:     com.eloancn.framework.cas.session.redis.RedisCacheManager
 * JD-Core Version:    0.6.0
 */